package com.talkweb.osmharmony.views.overlay.simplefastpoint;

import com.talkweb.osmharmony.util.GeoPoint;
import ohos.location.Location;
import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

/**
 * A {@link GeoPoint} with a label.
 * Created by Miguel Porto on 12-11-2016.
 */

public class LabelledGeoPoint extends GeoPoint {
    String mLabel;

    public LabelledGeoPoint(double aLatitude, double aLongitude) {
        super(aLatitude, aLongitude);
    }

    public LabelledGeoPoint(double aLatitude, double aLongitude, double aAltitude) {
        super(aLatitude, aLongitude, aAltitude);
    }

    public LabelledGeoPoint(double aLatitude, double aLongitude, double aAltitude, String aLabel) {
        super(aLatitude, aLongitude, aAltitude);
        this.mLabel = aLabel;
    }

    public LabelledGeoPoint(Location aLocation) {
        super(aLocation);
    }

    public LabelledGeoPoint(GeoPoint aGeopoint) {
        super(aGeopoint);
    }

    public LabelledGeoPoint(double aLatitude, double aLongitude, String aLabel) {
        super(aLatitude, aLongitude);
        this.mLabel = aLabel;
    }

    public LabelledGeoPoint(LabelledGeoPoint aLabelledGeopoint) {
        this(aLabelledGeopoint.getLatitude(), aLabelledGeopoint.getLongitude()
                , aLabelledGeopoint.getAltitude(), aLabelledGeopoint.getLabel());
    }

    public String getLabel() {
        return this.mLabel;
    }

    public void setLabel(String label) {
        this.mLabel = label;
    }

    @Override
    public LabelledGeoPoint clone() {
        return new LabelledGeoPoint(this.getLatitude(), this.getLongitude(), this.getAltitude()
                , this.mLabel);
    }

    // ===========================================================
    // Parcelable
    // ===========================================================
    private LabelledGeoPoint(final Parcel in) {
        super(in.readDouble(), in.readDouble(), in.readDouble());
        this.setLabel(in.readString());
    }

    @Override
    public boolean unmarshalling(Parcel in) {
        super.unmarshalling(in);
        this.mLabel = in.readString();
        return true;
    }

    @Override
    public boolean marshalling(Parcel out) {
        return super.marshalling(out) && out.writeString(mLabel);
    }

    public static final Sequenceable.Producer<LabelledGeoPoint> CREATOR = new Sequenceable.Producer<LabelledGeoPoint>() {

        @Override
        public LabelledGeoPoint createFromParcel(Parcel parcel) {
            return new LabelledGeoPoint(parcel);
        }

    };
}
